package model;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class Machine {
	String id;
	int neighborhood;
	int location;
	HashMap<String, Integer> capacities;
	HashMap<String, Integer> safetyCapacities;
	List<String> processes;
	HashMap<String, Integer> machineMoveCosts;

	public Machine() {
		capacities = new HashMap<String, Integer>();
		safetyCapacities = new HashMap<String, Integer>();
		processes = new ArrayList<String>();
		machineMoveCosts = new HashMap<String, Integer>();
	}

	public void setId(String id) {
		this.id = id;
	}

	public void setNeighborhood(int n) {
		this.neighborhood = n;
	}

	public void setLocation(int loc) {
		this.location = loc;
	}

	public void addCapacity(String s, int value) {
		capacities.put(s, value);
	}

	public void addSafetyCapacity(String s, int value) {
		safetyCapacities.put(s, value);
	}

	public void addMachineMoveCost(String s, int value) {
		machineMoveCosts.put(s, value);
	}
	
	public int getCapacityFor(String r_i_s){
		return capacities.get(r_i_s);
	}

	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append(String.format("ID=%s NEIGHBORHOOD=%s LOCATION=%s\n", id,
				neighborhood, location));
		sb.append("Capacities\n");
		for (String key : capacities.keySet()) {
			sb.append(String.format("%s->%d\n", key, capacities.get(key)));
		}
		sb.append("Safety Capacities\n");
		for (String key : safetyCapacities.keySet()) {
			sb.append(String.format("%s->%d\n", key, safetyCapacities.get(key)));
		}
		sb.append("MachineMoveCosts\n");
		for (String key : machineMoveCosts.keySet()) {
			sb.append(String.format("%s->%d\n", key, machineMoveCosts.get(key)));
		}

		return sb.toString();
	}

}
